import { request } from '@umijs/max';


/** 获取规则列表 GET /api/rule */
export async function fetchInvoiceList(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  const result =  await request('/api/mjBill/queryByPage', {
    method: 'POST',
    data: {
      ...params,
    },
    ...(options || {}),
  });
  return {data:result.data.records,success:true,total:result.data.total}  
}


/** 新建规则 POST /api/rule */
export async function downloadInvoice(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'POST',
    data: {
      method: 'post',
      ...(options || {}),
    },
  });
}

/** 删除规则 DELETE /api/rule */
export async function deleteInvoice(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/mjBill/delete', {
    method: 'POST',
    data: {
      method: 'delete',
      ...(options || {}),
    },
  });
}

//编辑
export async function updateInvoice(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/mjBill/edit', {
    method: 'POST',
    data: {
      method: 'update',
      ...(options || {}),
    },
  });
}
//开票完成
export async function finishInvoice(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/mjBill/completeBill', {
    method: 'POST',
    data: {
      ...(options || {}),
    },
  });
}

// 发票详情
export async function fetchInvoiceDetail(id : any) {
  return request('/api/mjBill/detail', {
    method: 'GET',
    params: {
      id: id
    },
  });
}